#include "server.h"

#include <QTcpServer>

#include "httpclient.h"


Server::Server(int port, QObject *parent) : QObject(parent)
{
    v_port = port;
    p_tcpServer = new QTcpServer(this);
}


int Server::port() const{
    return v_port;
}



void Server::start()
{
    p_tcpServer->listen(QHostAddress::Any, v_port);
    connect(p_tcpServer, SIGNAL(newConnection()), this, SLOT(connectClientSlot()));
}


void Server::stop()
{
    p_tcpServer->close();
}



// SLOTS

void Server::connectClientSlot()
{
    qDebug() << "Connection";
    connectClient();
}


void Server::disconnectClientSlot()
{
    qDebug() << "Disconnected";
    disconnectClient();
}
